home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 August: Tool Chest / Dev.CD Aug 95 TC / Dev.CD Aug 95 TC.toast / Tool Chest / Development Tools & Languages / Dylan Related / Mindy / Mindy 1.2 - portable sources / etc / generate-depends next >
Encoding:
Text File  |  1995-03-15  |  1.4 KB  |  51 lines  |  [TEXT/ttxt]

  1. #!/usr/misc/bin/perl
  2. # (Outside of cs.cmu.edu, that will probably be /usr/bin/perl)
  3.  
  4. # Will take the output of gcc -MM -E *.c and massage it so that it 
  5. # can be plugged right in to a Mindy Makefile.in
  6. # (Namely, it adds ${SRCDIR} to the front of each target, while trying to 
  7. # make the line breaks look halfway decent)
  8.  
  9. # Accesses and destroys the global array @words, which contains target, 
  10. # a colon, and a bunch of dependencies
  11. #
  12. sub print_target {
  13.     local($first_word) = shift @words;
  14.     local($colon) = shift @words;
  15.     local($c_file) = $words[0];
  16.     print $first_word, " : ";
  17.     local($count) = 0;
  18.     while (@words) {
  19.     local($this_word) = shift(@words);
  20.     print " \${SRCDIR}/", $this_word;
  21.     $count++;
  22.     if ($count == 3 && @words) {
  23.         $count = 0;
  24.         print " \\\n";
  25.         for ($i=0; $i<length($first_word . " : "); $i++) {
  26.         print " ";
  27.         }
  28.     }
  29.     }
  30.     print "\n\t\${CC} -c \${CFLAGS} \${SRCDIR}/", $c_file, "\n\n";
  31. }
  32.  
  33. while (<>) {
  34.     chop;
  35.     @these_words = split(" ", $_);
  36.     $this_line_escaped = 0;
  37.     if ($these_words[$#these_words] eq "\\") {
  38.     @these_words = @these_words[0..$#these_words - 1];
  39.     $this_line_escaped = 1;
  40.     }
  41.     if ($last_line_escaped) {
  42.     @words = (@words, @these_words);       # Concatenate them
  43.     } else {
  44.     @words = @these_words;
  45.     }
  46.     if (! $this_line_escaped) {
  47.     &print_target;
  48.     }
  49.     $last_line_escaped = $this_line_escaped;
  50. }    
  51.